<template>
    <div class="box">
        <h3 class="title">推荐文章</h3>
        <div class="recommendarticle" v-for="item in props.recommendValue">
            <img :src="item.thumbnail">
            <span @click="handleClick(item.id)">{{ item.title }}</span>
        </div>
    </div>
</template>


<script setup>
import { useRouter } from 'vue-router';
import { updateArticleViewCountAPI } from '@/api'

const router = useRouter()
const props = defineProps({
    recommendValue: {
        type: Array,
        default: []
    }
})
const handleClick = async (val) => {
    await updateArticleViewCountAPI(val)
    router.push({
        path: "/layout/articledetail",
        query: {
            articleId: val
        }
    }).catch(err => { })
}
</script>


<style lang="scss" scoped>
.box {
    border-radius: .5rem;
    padding: 2rem;
    overflow: hidden;
    border: .1rem solid #eee;
}

.box .title {
    font-size: 2.5rem;
    padding-bottom: 1.6rem;
    font-weight: 400;
}

.box .recommendarticle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding: 1rem;
    cursor: pointer;

    img {
        height: 8rem;
        width: 8rem;
    }

    span {
        font-size: 1.6rem;
        margin-left: 1rem;

        &:hover {
            color: orange;
        }
    }
}
</style>